package com.lb.tools.lbtools.tools.idcard;

import com.lb.tools.lbtools.tools.JsonUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.List;
import java.util.Map;

public class IdCardReader {


    @Value(value="classpath:idCardJson.json")
    private Resource resource;

    public void syncIcCardDataService() {
        try {
            StringBuffer message;
            String defaultString;
            try (BufferedReader br = new BufferedReader(new InputStreamReader(resource.getInputStream()))) {
                message = new StringBuffer();
                String line = null;
                while ((line = br.readLine()) != null) {
                    message.append(line);
                }
            }
            defaultString = message.toString();
            String result=defaultString.replace("\r\n", "").replaceAll(" +", "");
            Map<String, Object> map = JsonUtil.json2Map(result);
            Object[] objects = map.values().toArray();
            List<Map> list = (List) objects[0];
            for (Map map1 : list) {
                for (Object in : map1.keySet()) {
                    //存入redis中
                    //redisTemplate.opsForHash().put("idCardArray",in,map1.get(in));
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

}
